﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Dict.Dao;
using Dict.DataModel;

namespace Dict.Blo
{
    public class DictStoryBlo 
    {
        public static TableStory GetStory(int storyId)
        {
            return DictDataManager.Instance.tableStoryDao.GetById(storyId);
        }
        public static List<TableStory> GetStoryOfQuest(string questId)
        {
            return DictDataManager.Instance.tableStoryDao.GetByOneIndex(questId);
        }

        public static TableStoryQuest GetQuest(string questId)
        {
            return DictDataManager.Instance.tableStoryQuestDao.GetById(questId);
        }
        public static TableStoryQuest GetQuest(int order)
        {
            if(order<= DictDataManager.Instance.tableStoryQuestDao.CacheList.Count)
                return DictDataManager.Instance.tableStoryQuestDao.CacheList[order - 1];
            else
                return DictDataManager.Instance.tableStoryQuestDao.CacheList[0];

        }
        public static TableStoryQuest GetQuestOfMission(string missionId)
        {
            var list = DictDataManager.Instance.tableStoryQuestDao.GetByOneIndex(missionId);
            if (list.Count > 0)
                return list[0];
            return null;
        }

        public static List<TableStoryDialog> GetStoryDialogByStoryId(string storyId) {
            return Dict.DictDataManager.Instance.tableStoryDialogDao.GetByOneIndex(storyId);
        }

        public static TableStoryDialogHero GetTableStoryDialoHero(string id) {
            return Dict.DictDataManager.Instance.tableStoryDialogHeroDao.GetById(id);
        }

        /// <summary>
        /// 从屏蔽主角的表中取对话数据
        /// </summary>
        /// <param name="storyId"></param>
        /// <returns></returns>
        public static List<TableStoryDialog> GetStoryDialogByStoryId2(string storyId)
        {
            var list = new List<TableStoryDialog>();
            foreach(var data in DictDataManager.Instance.tableStoryDialog2Dao.GetByOneIndex(storyId))
            {
                TableStoryDialog tmp = new TableStoryDialog();
                tmp.background = data.background;
                tmp.content = data.content;
                tmp.faces0 = data.faces0;
                tmp.faces1 = data.faces1;
                tmp.faces2 = data.faces2;
                tmp.faces3 = data.faces3;
                tmp.groupId = data.groupId;
                tmp.heroIds0 = data.heroIds0;
                tmp.heroIds1 = data.heroIds1;
                tmp.heroIds2 = data.heroIds2;
                tmp.heroIds3 = data.heroIds3;
                tmp.heroPos0 = data.heroPos0;
                tmp.heroPos1 = data.heroPos1;
                tmp.heroPos2 = data.heroPos2;
                tmp.heroPos3 = data.heroPos3;
                tmp.id = data.id;
                tmp.name = data.name;
                tmp.sound = data.sound;
                tmp.talker = data.talker;
                list.Add(tmp);
            }
            return list;
        }

    }
}